using System;
using System.Collections.Generic;
using Sce.PlayStation.Core;
using Sce.PlayStation.Core.Graphics;
namespace Nyanimals
{
	public abstract class CBaseContext
	{
        public delegate void RenderAction();
        
		private bool active;
		private int meshIndex;
		private int shaderIndex;
		private float radius;
		private bool wireframe = false;
		protected Matrix4 worldMatrix;
		
        protected List<RenderAction> RenderActions = new List<RenderAction>();
		
        public void AddRenderAction(RenderAction act)
        {
            RenderActions.Add(act);
        }
		
		public bool Active
		{
			get { return active;}
			set { active = value;}
		}
		public int MeshIndex
		{
			get { return meshIndex;}
			set { meshIndex = value;}
		}
		public int ShaderIndex
		{
			get { return shaderIndex;}
			set { shaderIndex = value;}
		}
		public float Radius
		{
			get { return radius;}
			set { radius = value;}
		}
		public bool WireFrame
		{
			get { return wireframe;}
			set { wireframe = value;}
		}
		public Matrix4 WorldMatrix
		{
			get { return worldMatrix;}
			set { worldMatrix = value;}
		}
		
	    public void RotateY( float rot )
	    {
	        worldMatrix = worldMatrix * Matrix4.RotationY( rot );
	    }
	
	    public void RotateX( float rot )
	    {
	        worldMatrix = worldMatrix * Matrix4.RotationX( rot );
	    }
		
	    public Vector3 Position
	    {
	        set
			{
	            worldMatrix.ColumnW = new Vector4( value, 1.0f );
	        }
	        get{ return new Vector3( worldMatrix.M41, worldMatrix.M42, worldMatrix.M43 ); }
    }
		
		public virtual ContextTypes Type
		{
			get { return ContextTypes.Base_Context;}
		}
		public abstract void Render(GraphicsContext graphics);
	}
}

